<template>
  <div id="app">
    <el-card shadow="always">
      <template>
        <el-table
            :data="studentList"
            border
            style="width: 100%">
          <el-table-column
              label="学号"
              align="center"
              prop="sid"/>
          <el-table-column
              label="姓名"
              align="center"
              prop="sname"/>
          <el-table-column
              label="性别"
              align="center"
              prop="sex"/>
          <el-table-column
              label="年龄"
              align="center"
              prop="age"/>
          <el-table-column
              label="地址"
              align="center"
              prop="addr"/>
          <el-table-column
              label="所在班级"
              align="center"
              prop="cid"/>
          <el-table-column label="操作" align="center">
            <template slot-scope="scope">
              <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
              <el-button type="text" size="small">编辑</el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </el-card>
  </div>
</template>
<script>

import studentApi from "@/api/student";

export default {
  data() {
    return {
      studentList: [], //当前页的所有学生信息集合
    }
  },

  created() {
    this.findAllStudents()
  },
  methods: {
    async findAllStudents(){
      const {data:res} = await  studentApi.findAllStudents()
      console.log(res.data)
      if (res.code === 200){
        this.studentList = res.data.list
      }
    },
    handleClick(row) {
      console.log(row);
    },
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
  },

}

</script>
<style>
  #app{
    display: flex;
    justify-content: center;
  }
  .el-card{
    width: 90%;
  }
</style>
